home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mgr / atari / src.dif < prev   
C/C++ Source or Header  |  1990-09-30  |  27KB  |  1,126 lines

  1. Here are the diffs to the mgr/src subdirectory. I haven't provided Makefile
  2. diffs, because I ended up makeing a lot of strange changes ("Makefile" and my
  3. "make" didn't seem to be compatible, so I just hacked out everything that
  4. didn't work right and did it by hand). The only substantial difference was
  5. that I used BLITDIR=atari instead of BLITDIR=port.
  6.  
  7. *** src/orig/copyright.c    Sun Aug  5 13:56:54 1990
  8. --- src/copyright.c    Thu Sep 27 20:38:18 1990
  9. ***************
  10. *** 16,21 ****
  11. --- 16,24 ----
  12.   #include <sys/signal.h>
  13.   #include "bitmap.h"
  14.   #include "copyright.h"
  15. + #ifdef atarist
  16. + extern void _do_fly();
  17. + #endif
  18.   
  19.   #define SSIZE    3        /* star size */
  20.   
  21. ***************
  22. *** 43,48 ****
  23. --- 46,52 ----
  24.       BITMAP *notice = &cr;
  25.       int x = (BIT_WIDE(where)-BIT_WIDE(notice))/2;
  26.       int y = BIT_HIGH(where)/2;
  27.       int high = BIT_HIGH(logo[0]);
  28.       int wide = BIT_WIDE(logo[0]);
  29.       int mask = 1;        /* select mask (1 == kbd) */
  30. ***************
  31. *** 50,55 ****
  32. --- 54,65 ----
  33.       register int i;
  34.       char c;
  35.   
  36. + #ifdef atarist
  37. + /* make sure as much as possible fits on the screen */
  38. +     if (y < high + BIT_HIGH(notice)) {
  39. +             y = BIT_HIGH(where) - BIT_HIGH(notice);
  40. +     }
  41. + #endif
  42.       c1.x1 = x - SSIZE;
  43.       c1.y1 = y - SSIZE;
  44.       c1.x2 = BIT_WIDE(notice) + x;
  45. ***************
  46. *** 71,79 ****
  47.   
  48.       /* kick off stars */
  49.   
  50.       if ((pid=fork()) == 0) /* child */
  51.           fly(where,c1,c2);
  52. !    else {
  53.           for(i=0;select(32,&mask,0,0,&delay) <= 0;i++,mask=1)
  54.               bit_blit(where,x,y,wide,high,
  55.               BIT_SRC|GETCOLOR(BG_COLOR),
  56. --- 81,93 ----
  57.   
  58.       /* kick off stars */
  59.   
  60. + #ifdef atarist
  61. +     pid = tfork(_do_fly, where);
  62. + #else
  63.       if ((pid=fork()) == 0) /* child */
  64.           fly(where,c1,c2);
  65. !         else {
  66. ! #endif
  67.           for(i=0;select(32,&mask,0,0,&delay) <= 0;i++,mask=1)
  68.               bit_blit(where,x,y,wide,high,
  69.               BIT_SRC|GETCOLOR(BG_COLOR),
  70. ***************
  71. *** 81,92 ****
  72. --- 95,157 ----
  73.           read(0,&c,1);
  74.           kill(pid,SIGTERM);
  75.           while(wait(0)!=pid);
  76. + #ifndef atarist
  77.           }
  78. + #endif
  79.       }
  80.   
  81.   /* star trek effect */
  82.   
  83. + #ifdef atarist
  84. + /*
  85. +  * routines to fork off a thread to do the star flying
  86. +  */
  87. + #include <osbind.h>
  88. + #include <basepage.h>
  89. + #define STKSIZE 8192L
  90. + void
  91. + _start_thread(b)
  92. +     BASEPAGE *b;
  93. + {
  94. +     void (*func)();
  95. +     long arg;
  96. +     func = (void (*)())b->p_dbase;
  97. +     arg = b->p_dlen;
  98. +     func(arg);
  99. +     Pterm0();
  100. + }
  101. + int
  102. + tfork(func, arg)
  103. +     void (*func)();
  104. +     long arg;
  105. + {
  106. +     BASEPAGE *b;
  107. +     int pid;
  108. +     b = (BASEPAGE *)Pexec(PE_CBASEPAGE, 0L, "", 0L);
  109. +     Mshrink(b, STKSIZE);
  110. +     b->p_tbase = (char *)_start_thread;
  111. +     b->p_dbase = (char *)func;
  112. +     b->p_dlen = arg;
  113. +     pid = Pexec(104, 0L, b, 0L);
  114. +     return pid;
  115. + }
  116. + void
  117. + _do_fly(where)
  118. +     BITMAP *where;
  119. + {
  120. +     fly(where, c1, c2);
  121. + }
  122.   
  123. + #undef Random
  124. + #endif /* atarist */
  125.   /*
  126.    * porter.c  Steve Hawley 4/3/87
  127.    * rehacked 5/18/1988 for extra speed.
  128. ***************
  129. *** 131,137 ****
  130.                           stp->y = Random();
  131.                           stp->z = (Random() % MAXZ) + 1;
  132.                           stp->color = Random() % 23;
  133. !                                 if (stp->color == BG_COLOR)
  134.                               stp->color++;
  135.               
  136.                   } while(project(where,stp->x, stp->y, stp->z, stp->color, ON,clip1,clip2)); /* on screen? */
  137. --- 196,202 ----
  138.                           stp->y = Random();
  139.                           stp->z = (Random() % MAXZ) + 1;
  140.                           stp->color = Random() % 23;
  141. !             if (stp->color == BG_COLOR)
  142.                               stp->color++;
  143.               
  144.                   } while(project(where,stp->x, stp->y, stp->z, stp->color, ON,clip1,clip2)); /* on screen? */
  145. ***************
  146. *** 146,154 ****
  147.                                   stp->y = Random();
  148.                                   stp->z = MAXZ;
  149.                           }
  150. !                                 else {        /* rotate universe */
  151. !                                     cordic(&stp->x,&stp->y,SCALE,COUNT);
  152. !                                 }
  153.                           if (project(where,stp->x, stp->y, stp->z, stp->color, ON,clip1,clip2)) {
  154.                                   /* if projection is off screen, get a new position */
  155.                                   stp->x = Random();
  156. --- 211,219 ----
  157.                                   stp->y = Random();
  158.                                   stp->z = MAXZ;
  159.                           }
  160. !             else {        /* rotate universe */
  161. !                     cordic(&stp->x,&stp->y,SCALE,COUNT);
  162. !             }
  163.                           if (project(where,stp->x, stp->y, stp->z, stp->color, ON,clip1,clip2)) {
  164.                                   /* if projection is off screen, get a new position */
  165.                                   stp->x = Random();
  166. ***************
  167. *** 243,245 ****
  168. --- 308,311 ----
  169.      *x = tempx;
  170.      *y = tempy;
  171.   }
  172. *** src/orig/cut.c    Mon Sep 10 12:07:10 1990
  173. --- src/cut.c    Mon Sep 10 23:28:38 1990
  174. ***************
  175. *** 190,197 ****
  176. --- 190,202 ----
  177.            break;
  178.         }
  179.      *pntr = '\0';
  180. + #ifndef atarist
  181. + /* sigh -- these were allocated with fixed data, so freeing them causes
  182. +    big problems on the atari
  183. +  */
  184.      bit_destroy(check);
  185.      bit_destroy(glyph);
  186. + #endif
  187.   
  188.      /* put text into snarf buffer */
  189.   
  190. *** src/orig/defines.h    Sun Aug  5 13:55:44 1990
  191. --- src/defines.h    Mon Sep 17 01:28:58 1990
  192. ***************
  193. *** 41,49 ****
  194. --- 41,56 ----
  195.   #define SCREEN_DEV    "/dev/bwtwo0"    /* where to find the frame buffer */
  196.   #endif
  197.   #define MOUSE_DEV    "/dev/mouse"    /* where to find the mouse */
  198.   #define TERMNAME    "mgr"        /* name of termcap entry */
  199. + #ifdef atarist
  200. + #define STARTFILE    "mgr.rc"
  201. + #else
  202.   #define STARTFILE    ".mgrc"        /* name of mgr startup file */
  203.   #define HOST        "win "        /* name of host for utmp file */
  204. + #endif
  205.   #ifndef FONTDIR
  206.   #  define FONTDIR        "/usr/mgr/font" /* where to find the fonts */
  207.   #endif
  208. *** src/orig/defs.h    Mon Apr  3 09:09:46 1989
  209. --- src/defs.h    Mon Sep 10 12:23:10 1990
  210. ***************
  211. *** 23,31 ****
  212.   #ifdef DEBUG
  213.   extern char debug_level[];
  214.   char *index();
  215.   #define dprintf(x) \
  216.       if (debug && index(debug_level,'x')) fprintf
  217. ! #endif
  218.   
  219.   /* macros -- for speed */
  220.   
  221. --- 23,36 ----
  222.   #ifdef DEBUG
  223.   extern char debug_level[];
  224.   char *index();
  225. + # ifdef __STDC__
  226.   #define dprintf(x) \
  227. +     if (debug && index(debug_level,(#x)[0])) fprintf
  228. + # else
  229. + #define dprintf(x) \
  230.       if (debug && index(debug_level,'x')) fprintf
  231. ! # endif
  232. ! #endif /* DEBUG */
  233.   
  234.   /* macros -- for speed */
  235.   
  236. *** src/orig/destroy.c    Sun Aug  5 13:55:56 1990
  237. --- src/destroy.c    Thu Sep 27 20:38:30 1990
  238. ***************
  239. *** 35,41 ****
  240. --- 35,45 ----
  241.   register WINDOW *win;
  242.      {
  243.      int i;
  244. + #ifdef atarist
  245. +    int status;
  246. + #else
  247.      union wait status;
  248. + #endif
  249.   
  250.      if (win == (WINDOW *) 0)
  251.         return(-1);
  252. ***************
  253. *** 63,68 ****
  254. --- 67,75 ----
  255.   #ifdef DEBUG
  256.         dprintf(d)(stderr,"%s: destroy main %s\r\n",W(tty),W(alt)?"ALT":"");
  257.   #endif
  258. + #ifdef atarist
  259. +     if (W(pid) > 1)
  260. + #endif
  261.         killpg(W(pid),SIGHUP);
  262.   
  263.         if (geteuid() < 1) {
  264. ***************
  265. *** 87,97 ****
  266. --- 94,112 ----
  267.         dprintf(d)(stderr,"waiting for ..."); fflush(stderr);
  268.   #endif
  269.         if (W(pid) > 1) {
  270. + #ifdef atarist
  271. +          wait(&status);
  272. +      if ( (status & 0177) == 0177 ) {
  273. +         kill(W(pid), SIGCONT);
  274. +         wait(&status);
  275. +     }
  276. + #else
  277.            i = wait3(&status,WNOHANG,0L);
  278.            if (i == 0) {                     /* start it so it can die */
  279.               kill(W(pid),SIGCONT);
  280.               wait(&status);
  281.               }
  282. + #endif
  283.            }
  284.   #ifdef DEBUG
  285.         dprintf(d)(stderr," %d\r\n",i);
  286. *** src/orig/do_button.c    Sun Aug  5 13:56:00 1990
  287. --- src/do_button.c    Thu Sep 27 20:39:36 1990
  288. ***************
  289. *** 253,258 ****
  290. --- 253,261 ----
  291.      /* fix pttys */
  292.      if (geteuid() < 2)
  293.         for(win=active;win != (WINDOW *) 0;win=W(next)) {
  294. + #ifdef atarist
  295. +         if (W(pid) > 1)
  296. + #endif
  297.               killpg(W(pid),SIGHUP);
  298.            chmod(W(tty),0666);
  299.            chown(W(tty),0,0);
  300. *** src/orig/down_load.c    Sun Aug  5 13:56:04 1990
  301. --- src/down_load.c    Tue Sep 11 16:57:06 1990
  302. ***************
  303. *** 172,177 ****
  304. --- 172,181 ----
  305.   
  306.                      if (c == '/' || (c == '.' && W(snarf)[1]=='/'))
  307.                         strcpy(filename,W(snarf));
  308. + #ifdef atarist
  309. +            else if (c == '\\' || (c && W(snarf)[1] == ':'))
  310. +                strcpy(filename,W(snarf));
  311. + #endif
  312.                      else
  313.                         sprintf(filename,"%s/%s",icon_dir,W(snarf));
  314.   
  315. ***************
  316. *** 239,246 ****
  317. --- 243,252 ----
  318.   #ifdef DEBUG
  319.                         dprintf(y)(stderr,"saving bitmap %d x %d on %s (%d)\n",BIT_WIDE(b),BIT_HIGH(b),W(snarf),fileno(fp));
  320.   #endif
  321. + #ifndef atarist
  322.                         if (exists<0)    /* file just created */
  323.                            fchown(fileno(fp),getuid(),getgid());
  324. + #endif
  325.                         bitmapwrite( fp, b, get_bm_type() );
  326.                         fclose(fp);
  327.   #ifdef DEBUG
  328. *** src/orig/get_menu.c    Sun Sep  9 11:52:20 1990
  329. --- src/get_menu.c    Sun Sep 23 20:37:26 1990
  330. ***************
  331. *** 64,70 ****
  332. --- 64,75 ----
  333.   #define HIGH        (font->head.high+2)
  334.   
  335.   extern BITMAP mouse_bull, mouse_bull2;
  336. + #ifdef atarist
  337. + static unsigned int save_bits[BLIP];
  338. + #else
  339.   static unsigned short save_bits[BLIP];
  340. + #endif
  341.   static bit_static(track,BLIP,BLIP,save_bits,DEPTH);
  342.   
  343.   /* allocate space for and initialize menu */
  344. ***************
  345. *** 279,285 ****
  346. --- 284,294 ----
  347.            done++;
  348.            }
  349.   
  350. + #ifdef atarist
  351. +       x_position = BETWEEN(1, x_position, BIT_WIDE(inside) - 1);
  352. + #else
  353.         x_position = BETWEEN(BLIP/2, x_position, BIT_WIDE(inside) - BLIP/2);
  354. + #endif
  355.   
  356.         TRACKON(inside,x_position,y_position);        /* on */
  357.   
  358. *** src/orig/getshell.c    Sun Aug  5 13:56:14 1990
  359. --- src/getshell.c    Thu Sep 27 20:40:08 1990
  360. ***************
  361. *** 19,28 ****
  362.   #include "bitmap.h"
  363.   #include "defs.h"
  364.   
  365.   #define SHELL        "/bin/sh"
  366.   static char line[] = {"/dev/ptypX"};
  367.   static int  pty_index=5;        /* better hit rate than 0 */
  368.   extern char **environ;
  369.   
  370.   /*    get a pty line */
  371. --- 19,36 ----
  372.   #include "bitmap.h"
  373.   #include "defs.h"
  374.   
  375. + #ifdef atarist
  376. + #include <osbind.h>
  377. + #include <mintbind.h>
  378. + #define SHELL        "init.prg"
  379. + static char line[] = {"Q:\\ttyp.XX"};
  380. + static int pty_index = 0;
  381. + #else
  382.   #define SHELL        "/bin/sh"
  383.   static char line[] = {"/dev/ptypX"};
  384.   static int  pty_index=5;        /* better hit rate than 0 */
  385. + #endif
  386.   extern char **environ;
  387.   
  388.   /*    get a pty line */
  389. ***************
  390. *** 33,45 ****
  391. --- 41,60 ----
  392.      register int i;
  393.      int fd;
  394.   
  395. + #ifndef atarist
  396.      line[5] = 'p';
  397. + #endif
  398.      for(line[8]='p';line[8]<'r';line[8]+= 1)
  399.         for (i=1;i<=16;i++) {
  400.            line[9]="0123456789abcdef"[(pty_index+i)%16];
  401. + #ifdef atarist
  402. +      if ((fd = Fcreate(line, FA_SYSTEM|FA_HIDDEN)) >= 0) {
  403. + #else
  404.            if ((fd = open(line,2)) >= 0) {
  405.               /* pty_index = (pty_index+i)%16;   temp */
  406.               line[5] = 't';
  407. + #endif
  408.               return(fd);
  409.               }
  410.            }
  411. ***************
  412. *** 49,55 ****
  413. --- 64,74 ----
  414.   int getatty()
  415.      {
  416.      int fd;
  417. + #ifndef atarist
  418.      line[5]='t';
  419. + #endif
  420.      fd=open(line,2);
  421.      if (fd<0) {
  422.         sleep(3);
  423. ***************
  424. *** 106,112 ****
  425. --- 125,133 ----
  426.      if ((pid=fork()) > 0) {
  427.         /* parent side of fork */
  428.         char buff[2];
  429. + #ifndef atarist
  430.         read(*file,buff,sizeof(buff));    /* wait for slave side to open */
  431. + #endif
  432.   #ifdef DEBUG
  433.         dprintf(s)(stderr,"EXEC done, slave side open\r\n ");
  434.   #endif
  435. ***************
  436. *** 146,151 ****
  437. --- 167,173 ----
  438.   
  439.      for(i=0;i<tty_slots;i++) if (i != fd) close(i);
  440.   
  441. + #ifndef atarist
  442.      /* set the uid-0 stuff up */
  443.   
  444.      if (geteuid() < 1) {
  445. ***************
  446. *** 163,172 ****
  447. --- 185,202 ----
  448.      close(fd);
  449.      dup(i);
  450.      dup(i);
  451. + #else
  452. +    Fforce(-1, fd);
  453. +    Fforce(0, fd);
  454. +    Fforce(1, fd);
  455. +    Fforce(2, fd);
  456. +    Fclose(fd);
  457. + #endif
  458.   
  459.      setpgrp(group,group);
  460.      ioctl(0,TIOCSPGRP,&group);
  461.   
  462. + #ifndef atarist
  463.       adjust_mode(NTTYDISC,ECHO|CRMOD|EVENP|ODDP);
  464.       restore_modes(0);
  465.   
  466. ***************
  467. *** 176,181 ****
  468. --- 206,212 ----
  469.      add_utmp(0,sprintf(who,"%s%c",HOST,line[9]));
  470.   #endif
  471.   
  472. + #endif /* atarist */
  473.      /* start the command */
  474.   
  475.   #ifdef DEBUG
  476. ***************
  477. *** 185,191 ****
  478. --- 216,224 ----
  479.      do_env("TERM=",TERMNAME);
  480.      do_env("TERMCAP=","");
  481.   
  482. + #ifndef atarist
  483.      write(2,"\n",1);    /* tell master that slave side is open */
  484. + #endif
  485.      execve(name,argv,environ);
  486.      _exit(1);
  487.      }
  488. ***************
  489. *** 201,212 ****
  490. --- 234,258 ----
  491.   
  492.      if ((*file=getapty()) < 0)
  493.         return((char *) 0);
  494. + #ifndef atarist
  495.      ioctl(*file,TIOCREMOTE,0);    /* I dunno */
  496. + #endif
  497.      return(line);
  498.      }
  499.   
  500.   /* get a complete path name from command */
  501.   
  502. + #ifdef atarist
  503. + char *
  504. + get_path(name)
  505. + char *name;
  506. +    {
  507. +    char *getenv(), *findfile();
  508. +    static char *extensions[] = { "ttp", "prg", "tos", 0 };
  509. +    return findfile(name, getenv("PATH"), extensions);
  510. +    }
  511. + #else
  512.   static char path[512];
  513.   static char start[512];
  514.   
  515. ***************
  516. *** 239,244 ****
  517. --- 285,291 ----
  518.         return((char *) 0);
  519.         }
  520.      }
  521. + #endif /* atarist */
  522.   
  523.   /* change an environment variable */
  524.   
  525. *** src/orig/kbd.c    Sun Aug  5 13:56:20 1990
  526. --- src/kbd.c    Thu Sep 27 20:40:32 1990
  527. ***************
  528. *** 12,17 ****
  529. --- 12,21 ----
  530.   
  531.   #include <stdio.h>
  532.   #include <sys/signal.h>
  533. + #ifdef atarist
  534. + #include <osbind.h>
  535. + #endif
  536.   #include "bitmap.h"
  537.   #include "defs.h"
  538.   #ifdef sun
  539. ***************
  540. *** 65,70 ****
  541. --- 69,77 ----
  542.   
  543.      write( 2, "\007", 1 );
  544.   */
  545. + #ifdef atarist
  546. +    Bconout(2, 7);
  547. + #endif
  548.      }
  549.   
  550.   #ifdef BELL
  551. *** src/orig/mgr.c    Tue Apr 24 09:28:06 1990
  552. --- src/mgr.c    Thu Sep 27 20:36:50 1990
  553. ***************
  554. *** 14,20 ****
  555. --- 14,30 ----
  556.   
  557.   #include "bitmap.h"
  558.   #include <stdio.h>
  559. + #ifdef atarist
  560. + #include <osbind.h>
  561. + #include <signal.h>
  562. + #include <time.h>
  563. + long _stksize = 32*1024L;
  564. + extern int __mint;
  565. + #else
  566.   #include <sys/signal.h>
  567. + #endif
  568.   #ifdef sun
  569.   #include <sys/time.h> 
  570.   #endif
  571. ***************
  572. *** 29,35 ****
  573.   #endif
  574.   #define POLL(poll)        (poll&mask ? &set_poll : (struct timeval *) 0)
  575.   
  576. ! #ifdef sun
  577.   struct timeval set_poll = {
  578.      (long) 0, (long) POLL_INT
  579.      };                /* set select to poll */
  580. --- 39,45 ----
  581.   #endif
  582.   #define POLL(poll)        (poll&mask ? &set_poll : (struct timeval *) 0)
  583.   
  584. ! #if defined(sun) || defined(atarist)
  585.   struct timeval set_poll = {
  586.      (long) 0, (long) POLL_INT
  587.      };                /* set select to poll */
  588. ***************
  589. *** 56,72 ****
  590.      char *screen_dev = SCREEN_DEV;    /* name of frame buffer */
  591.      char *default_font = (char * )0;    /* default font */
  592.      char *rindex(), *getenv(), *ttyname();
  593.      char *term = getenv("TERM");        /* place to put terminal name */
  594.   #ifdef SHRINK
  595.      BITMAP *prime;
  596.   #endif
  597.   
  598.      SETMOUSEICON(&mouse_arrow);
  599. !     timestamp();                            /* initialize the timestamp */
  600.   
  601.      /* process arguments */
  602.   
  603.      sprintf(start_file,"%s/%s",getenv("HOME"),STARTFILE);
  604.      while(--argc > 0) {
  605.         argv++;
  606.   #ifdef DEBUG
  607. --- 66,105 ----
  608.      char *screen_dev = SCREEN_DEV;    /* name of frame buffer */
  609.      char *default_font = (char * )0;    /* default font */
  610.      char *rindex(), *getenv(), *ttyname();
  611. + #ifdef atarist
  612. +    char *term;
  613. + #else
  614.      char *term = getenv("TERM");        /* place to put terminal name */
  615. + #endif
  616.   #ifdef SHRINK
  617.      BITMAP *prime;
  618.   #endif
  619.   
  620. + #ifdef atarist
  621. +    _binmode(1);
  622. +    if (__mint < 6) {
  623. +     fprintf(stderr, "MGR requires MiNT version 0.6 or higher\n");
  624. +     exit(2);
  625. +    }
  626. +    printf("\033E\033f");    /* clear screen, turn off cursor */
  627. +    fflush(stdout);
  628. + #endif
  629.      SETMOUSEICON(&mouse_arrow);
  630. !    timestamp();                            /* initialize the timestamp */
  631.   
  632.      /* process arguments */
  633.   
  634. + #ifdef atarist
  635. +    term = getenv("MGRFONT"); if (term) font_dir = term;
  636. +    term = getenv("MGRICON"); if (term) icon_dir = term;
  637. +    term = getenv("HOME"); if (!term) term = "";
  638. +    sprintf(start_file, "%s/%s", term, STARTFILE);
  639. +    term = getenv("TERM");
  640. + #else
  641.      sprintf(start_file,"%s/%s",getenv("HOME"),STARTFILE);
  642. + #endif
  643.      while(--argc > 0) {
  644.         argv++;
  645.   #ifdef DEBUG
  646. ***************
  647. *** 157,162 ****
  648. --- 190,196 ----
  649.      /* free all unused fd's */
  650.   
  651.      count = getdtablesize();
  652.      for(i=3;i<count;i++)
  653.         close(i);
  654.   
  655. ***************
  656. *** 227,233 ****
  657. --- 261,271 ----
  658.                           break;
  659.         case SIGILL:    /* <= 3.0 abort gererates this one */
  660.         case SIGCONT:
  661. + #ifdef atarist
  662. +       case SIGABRT:
  663. + #else
  664.         case SIGIOT:    /* 3.2 abort generates this (gee thanks, SUN!) */
  665. + #endif
  666.         case SIGQUIT:
  667.                           break;
  668.         case SIGTTIN:
  669. ***************
  670. *** 300,306 ****
  671.         dprintf(l)(stderr,"select: mask=0x%x poll=0x%x 0x%x got\r\n",
  672.                    mask,poll,reads);
  673.   #endif
  674. ! #ifdef sun
  675.         if (select(32,&reads,0,0,POLL(poll)) <0) {
  676.   #ifdef DEBUG
  677.            dprintf(l)(stderr,"select failed %d->%d\r\n",
  678. --- 338,344 ----
  679.         dprintf(l)(stderr,"select: mask=0x%x poll=0x%x 0x%x got\r\n",
  680.                    mask,poll,reads);
  681.   #endif
  682. ! #if defined(sun) || defined(atarist)
  683.         if (select(32,&reads,0,0,POLL(poll)) <0) {
  684.   #ifdef DEBUG
  685.            dprintf(l)(stderr,"select failed %d->%d\r\n",
  686. ***************
  687. *** 329,342 ****
  688.         /* process keyboard input */
  689.         
  690.         if (reads&1 && active && !(ACTIVE(flags)&W_NOINPUT)) {
  691.            read(0,&c,1);
  692. ! #ifdef BUCKEY
  693.            if ( (ACTIVE(flags)&W_NOBUCKEY)  ||  !do_buckey(c) )
  694.               write(ACTIVE(to_fd),&c,1);
  695. ! #else
  696.            write(ACTIVE(to_fd),&c,1);
  697. ! #endif
  698. !             if (ACTIVE(flags)&W_DUPKEY && c==ACTIVE(dup))
  699.                write(ACTIVE(to_fd),&c,1);
  700.            continue;
  701.            }
  702. --- 367,390 ----
  703.         /* process keyboard input */
  704.         
  705.         if (reads&1 && active && !(ACTIVE(flags)&W_NOINPUT)) {
  706. + #ifdef atarist
  707. + # ifdef BUCKEY
  708. +          if ( kbd_getch(&c) || (ACTIVE(flags)&W_NOBUCKEY)  ||  !do_buckey(c) )
  709. +             write(ACTIVE(to_fd),&c,1);
  710. + # else
  711. +      kbd_getch(&c);
  712. +          write(ACTIVE(to_fd),&c,1);
  713. + # endif
  714. + #else
  715.            read(0,&c,1);
  716. ! # ifdef BUCKEY
  717.            if ( (ACTIVE(flags)&W_NOBUCKEY)  ||  !do_buckey(c) )
  718.               write(ACTIVE(to_fd),&c,1);
  719. ! # else
  720.            write(ACTIVE(to_fd),&c,1);
  721. ! # endif
  722. ! #endif /* atarist */
  723. !      if (ACTIVE(flags)&W_DUPKEY && c==ACTIVE(dup))
  724.                write(ACTIVE(to_fd),&c,1);
  725.            continue;
  726.            }
  727. ***************
  728. *** 498,503 ****
  729. --- 546,563 ----
  730.   int
  731.   timestamp()
  732.       {
  733. + #ifdef atarist
  734. +     static long offset = 0;
  735. +     if (offset == 0) {
  736. +         offset = clock();
  737. +         return 0;
  738. +         }
  739. +     else {
  740. +         return (clock() - offset)/2;    /* clock is 200 HZ */
  741. +         }
  742. +     }
  743. + #else
  744.       static long offset = 0;
  745.       struct timeval timeval;
  746.       
  747. ***************
  748. *** 511,513 ****
  749. --- 571,646 ----
  750.           return((timeval.tv_sec - offset) * 100 + timeval.tv_usec / 10000);
  751.           }
  752.       }
  753. + #endif /* atarist */
  754. + #ifdef atarist
  755. + /* routine for reading the keyboard -- returns 1 if the key should be
  756. +    passed directly to the application, 0 if it might be a buckey key
  757. +    (i.e. if the ALT key was depressed)
  758. +  */
  759. + #include <osbind.h>
  760. + #define MAXSCAN 0x39
  761. + /* table for normal (unshifted) keys */
  762. + char normtab[MAXSCAN + 1] = {
  763. +    0, '\033', '1', '2', '3', '4', '5', '6',    /* 0 - 0x7     */
  764. +  '7', '8', '9', '0', '-', '=', '\010', '\011',    /* 0x8 - 0xf    */
  765. +  'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',    /* 0x10 - 0x17    */
  766. +  'o', 'p', '[', ']', '\r', 0, 'a', 's',        /* 0x18 - 0x1f    */
  767. +  'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',    /* 0x20 - 0x27    */
  768. +  '\'', '`', 0, '\\', 'z', 'x', 'c', 'v',    /* 0x28 - 0x2f    */
  769. +  'b', 'n', 'm', ',', '.', '/', 0, 0,        /* 0x30 - 0x37  */
  770. +   0, ' ' };                    /* 0x38 - 0x39    */
  771. + /* table for shifted keys */
  772. + char shfttab[MAXSCAN + 1] = {
  773. +    0, '\033', '!', '@', '#', '$', '%', '^',    /* 0 - 0x7     */
  774. +  '&', '*', '(', ')', '_', '+', '\010', '\011',    /* 0x8 - 0xf    */
  775. +  'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',    /* 0x10 - 0x17    */
  776. +  'O', 'P', '{', '}', '\r', 0, 'A', 'S',        /* 0x18 - 0x1f    */
  777. +  'D', 'F', 'G', 'H', 'J', 'K', 'L', ':',    /* 0x20 - 0x27    */
  778. +  '"', '~', 0, '|', 'Z', 'X', 'C', 'V',        /* 0x28 - 0x2f    */
  779. +  'B', 'N', 'M', '<', '>', '?', 0, 0,        /* 0x30 - 0x37  */
  780. +  0, ' ' };                    /* 0x38 - 0x39    */
  781. + #define _SHFT    0x3
  782. + #define _CTRL    0x4
  783. + #define _ALT    0x8
  784. + int
  785. + kbd_getch(c)
  786. +     char *c;
  787. + {
  788. +     long r;
  789. +     int scan, key, shft;
  790. +     r = Crawio(0xff);
  791. +     key = r & 0xff;
  792. +     shft = Kbshift(-1);
  793. +     if (key == 0) {
  794. +         scan = (r & 0x00ff0000) >> 16;
  795. +         if (scan >= 0x78 && scan <= 0x83) {
  796. +         /* compensate for TOS's silly ALT key remapping */
  797. +             scan = scan - 0x76;
  798. +         }
  799. +         if ( (scan <= MAXSCAN) && (shft & _ALT) ) {
  800. +             if (shft & _CTRL)
  801. +                 key = shfttab[scan] & 0x1f;
  802. +             else if (shft & _SHFT)
  803. +                 key = shfttab[scan];
  804. +             else
  805. +                 key = normtab[scan];
  806. +         }
  807. +     }
  808. +     if (shft & _ALT) {
  809. +         *c = key | 0x80;
  810. +         return 0;    /* might be buckey */
  811. +     }
  812. +     else {
  813. +         *c = key;
  814. +         return 1;    /* not buckey */
  815. +     }
  816. + }
  817. + #endif /* atarist */
  818. *** src/orig/set_mode.c    Tue Apr 24 09:37:32 1990
  819. --- src/set_mode.c    Sat Aug 11 22:24:24 1990
  820. ***************
  821. *** 28,36 ****
  822. --- 28,40 ----
  823.   int set_mouseio(file)
  824.   int file;                /* file descriptor */
  825.      {
  826. + #ifdef atarist
  827. +    return 0;
  828. + #else
  829.      set_mode(file,RAW,ECHO,B1200);
  830.      fcntl(file,F_SETFL,fcntl(file,F_GETFL,0)|FNDELAY); /* for 4.1 */
  831.      return(ioctl(file,TIOCEXCL,0));
  832. + #endif
  833.      }
  834.   
  835.   /* reset input tty modes */
  836. ***************
  837. *** 69,77 ****
  838. --- 73,85 ----
  839.      {
  840.      int tty;
  841.   
  842. + #ifdef atarist
  843. +    close(-1);
  844. + #else
  845.      tty = open("/dev/tty",2);
  846.      ioctl(tty,TIOCNOTTY,0);
  847.      close(tty);
  848. + #endif
  849.      }
  850.   
  851.   /*********************************************************************/
  852. ***************
  853. *** 89,109 ****
  854. --- 97,121 ----
  855.   save_modes(fd)
  856.   int fd;            /* fd to save tty modes from */
  857.       {
  858. + #ifndef atarist
  859.      ioctl(fd,TIOCGETD,&t_ldisc);
  860.      ioctl(fd,TIOCGETP,&t_sgttyb);
  861.      ioctl(fd,TIOCGETC,&t_tchars);
  862.      ioctl(fd,TIOCGLTC,&t_ltchars);
  863.      ioctl(fd,TIOCLGET,&t_lflags);
  864. + #endif
  865.       }
  866.   
  867.   restore_modes(fd)
  868.   int fd;
  869.       {
  870. + #ifndef atarist
  871.      ioctl(fd,TIOCSETD,&t_ldisc);
  872.      ioctl(fd,TIOCSETP,&t_sgttyb);
  873.      ioctl(fd,TIOCSETC,&t_tchars);
  874.      ioctl(fd,TIOCSLTC,&t_ltchars);
  875.      ioctl(fd,TIOCLSET,&t_lflags);
  876. + #endif
  877.       }
  878.   
  879.   adjust_mode(disc,flags)
  880. ***************
  881. *** 110,115 ****
  882. --- 122,129 ----
  883.   int flags;        /* flags */
  884.   int disc;        /* line disc */
  885.       {
  886. + #ifndef atarist
  887.      t_ldisc=disc;
  888.      t_sgttyb.sg_flags = flags;
  889. + #endif
  890.       }
  891. *** src/orig/sigdata.c    Sun Aug  5 13:56:36 1990
  892. --- src/sigdata.c    Sat Aug 11 01:23:48 1990
  893. ***************
  894. *** 12,17 ****
  895. --- 12,18 ----
  896.   
  897.   #include <stdio.h>
  898.   
  899. + #ifndef atarist
  900.   /* signal names, descriptions (for debugging) */
  901.   
  902.   struct signame {
  903. ***************
  904. *** 62,64 ****
  905. --- 63,78 ----
  906.      fflush(stderr);
  907.      abort();
  908.      }
  909. + #else /* atarist */
  910. + int
  911. + catch(sig)
  912. + int sig;
  913. + {
  914. +     extern char *sys_siglist[];
  915. +     _quit();
  916. +     fprintf(stderr, "got a %s\r\n", sys_siglist[sig]);
  917. +     fflush(stderr);
  918. +     abort();
  919. + }
  920. + #endif /* atarist */
  921. *** src/orig/subs.c    Fri Jun  9 09:02:40 1989
  922. --- src/subs.c    Thu Sep 27 20:41:08 1990
  923. ***************
  924. *** 446,456 ****
  925. --- 446,458 ----
  926.      sleep(1);                /* wait for CONT signal */
  927.      signal(SIGTSTP, catch);
  928.   
  929. + #ifndef atarist
  930.      if (set_kbd(1) != 0) {    /* reopen kbd (as 0) */
  931.         _quit();
  932.         fprintf(stderr,"Sorry, Can't reopen kbd\n");
  933.         exit(1);
  934.         }
  935. + #endif
  936.      mouse = mouse_reopen();
  937.      set_tty(0);
  938.      bell_on();    /* this resets the keyboard! */
  939. ***************
  940. *** 654,659 ****
  941. --- 656,664 ----
  942.   system(command)
  943.   char *command;
  944.   {
  945. + #ifdef atarist
  946. +     char *shell;
  947. + #endif
  948.           int status, pid, w;
  949.           register int (*istat)(), (*qstat)();
  950.   
  951. ***************
  952. *** 668,677 ****
  953. --- 673,691 ----
  954.                   setreuid(uid,uid);
  955.                   setregid(gid,gid);
  956.   
  957. + #ifdef atarist
  958. +         uid = open("V:\\NULL", 0);
  959. +         dup2(uid, 0);
  960. +         close(uid);
  961. +         shell = getenv("SHELL");
  962. +         if (!shell) shell = "ksh";
  963. +         execlp(shell, shell, "-c", command, 0);
  964. + #else
  965.           close(0);
  966.           open("/dev/null",0);
  967.   
  968.                   execl("/bin/sh", "sh", "-c", command, 0);
  969. + #endif
  970.                   _exit(127);
  971.           }
  972.           istat = signal(SIGINT, SIG_IGN);
  973. *** src/orig/utmp.c    Sun Aug  5 13:56:42 1990
  974. --- src/utmp.c    Sat Sep  8 01:42:48 1990
  975. ***************
  976. *** 12,17 ****
  977. --- 12,18 ----
  978.   
  979.   /* manage utmp file */
  980.   
  981. + #ifndef atarist
  982.   #include <pwd.h>
  983.   #include <utmp.h>
  984.   #include <sys/file.h>
  985. ***************
  986. *** 24,29 ****
  987. --- 25,31 ----
  988.   static struct utmp    entry, save_entry;
  989.   static char        zap[sizeof(entry)];
  990.   static int        save_slot;
  991. + #endif
  992.   
  993.   /* remove an entry from utmp file */
  994.   
  995. ***************
  996. *** 78,83 ****
  997. --- 80,86 ----
  998.   char *host;
  999.   int flag;
  1000.      {
  1001. + #ifndef atarist
  1002.      char *ttyname(), *rindex();
  1003.      long time();
  1004.      struct passwd *getpwuid();
  1005. ***************
  1006. *** 113,118 ****
  1007. --- 116,122 ----
  1008.         return(tty);
  1009.         }
  1010.      return(-1);
  1011. + #endif /* atarist */
  1012.      }
  1013.   
  1014.   /* remove utmp entry service routine */
  1015. ***************
  1016. *** 122,127 ****
  1017. --- 126,132 ----
  1018.   char *line;
  1019.   int flag;
  1020.      {
  1021. + #ifndef atarist
  1022.      int tty;
  1023.      int fd;
  1024.      FILE *file;
  1025. ***************
  1026. *** 160,163 ****
  1027. --- 165,169 ----
  1028.         return(tty);
  1029.         }
  1030.      return(-1);
  1031. + #endif /* atarist */
  1032.      }
  1033. *** src/orig/Write.c    Sun Aug  5 13:55:48 1990
  1034. --- src/Write.c    Tue Sep 11 05:03:12 1990
  1035. ***************
  1036. *** 20,25 ****
  1037. --- 20,47 ----
  1038.   
  1039.   extern errno;
  1040.   
  1041. + #ifdef atarist
  1042. + int
  1043. + Write(fd,buff,len)
  1044. + register int fd, len;
  1045. + register char *buff;
  1046. +    {
  1047. +    register int count = 0;
  1048. +    register int r;
  1049. +    while (count < len) {
  1050. +       r = write(fd, buff+count, len - count);
  1051. +       if (r < 0)
  1052. +          break;
  1053. +       else
  1054. +          count += r;
  1055. +    }
  1056. +    return count;
  1057. +    }
  1058. +    
  1059. + #else
  1060.   int
  1061.   Write(fd,buff,len)
  1062.   register int fd, len;
  1063. ***************
  1064. *** 44,46 ****
  1065. --- 66,69 ----
  1066.         }
  1067.      return(count);
  1068.      }
  1069. + #endif /* atarist */
  1070. *** src/orig/write_ok.c    Sun Aug  5 13:56:48 1990
  1071. --- src/write_ok.c    Tue Sep 18 19:35:40 1990
  1072. ***************
  1073. *** 68,75 ****
  1074. --- 68,79 ----
  1075.   char *name;        /* file to check mode for */
  1076.   int mask;        /* these bits must be turned off */
  1077.      {
  1078. + #ifdef atarist
  1079. +    return 1;        /* security? we don't need no steenking security :-( */
  1080. + #else
  1081.      struct stat buff;
  1082.      if (stat(name,&buff) < 0)
  1083.         return(0);
  1084.      return((buff.st_mode&mask) == 0);
  1085. + #endif
  1086.      }
  1087.